const express = require("express");
const app = express();

const port = process.env.PORT || 5000;


app.all("*", function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "content-type");
  res.header("Access-Control-Allow-Methods", "PUT,DELETE,GET,POST,OPTIONS");

  next();
});

app.get("/", (req, res) => {
  res.send("娃哈哈!~~~!");
});
/**
 * 根据不同的url进行数据请求
 */
app.get("/force", function (req, res) {
  res.json(require("./dataForTopology/force_directed.json"));
});

app.get("/dendrogram", function (req, res) {
  res.json(require("./dataForTopology/tree_dendrogram.json"));
});

app.get("/comboForce", function (req, res) {
  // console.log(req)
  res.json(require("./dataForTopology/combo_force.json"));
});

app.get("/highLight", function (req, res) {
  res.json(require("./dataForTopology/heightlight.json"));
});

app.get("/edgesEvent", function (req, res) {
  res.json(require("./dataForTopology/edges_events.json"));
});

app.get("/anchorPoints", function (req, res) {
  res.json(require("./dataForTopology/anchor_points.json"));
});



app.listen(port, () => {
  console.log(`server running on port ${port}`);
});